/**
 * Created by Francis.LW on 2017/10/20.
 *
 * 组织服务接口
 */
import {postRequest, getRequest} from '@/common/request'
import {urls} from './url'

const organizationApi = urls.organization

/**
 * 获取所有组织
 * @param param
 * @param page
 * @param pageSize
 * @param success
 * @param complete
 */
function listAllOrganization(param, success, complete) {
  postRequest(organizationApi.listAllOrganization, {}, param, success, complete)
}

/**
 * 获取组织列表
 * @param param
 * @param page
 * @param pageSize
 * @param success
 * @param complete
 */
function listOrganization(param, page, pageSize, success, complete) {
  postRequest(organizationApi.listOrganization + '?currentpage=' + page + '&pagesize=' + pageSize, {}, param, success, complete)
}

/**
 * 创建新组织
 * @param param
 * @param success
 * @param complete
 */
function addOrganization(param, success, complete) {
  postRequest(organizationApi.addOrganization, {}, param, success, complete)
}

/**
 * 更新组织信息
 * @param id
 * @param param
 * @param success
 * @param complete
 */
function updateOrganization(id, param, success, complete) {
  postRequest(organizationApi.updateOrganization + id, {}, param, success, complete)
}

/**
 * 获取组织信息
 * @param id
 * @param success
 * @param complete
 */
function getOrganizationById(id, success, complete) {
  getRequest(organizationApi.getOrganizationById + id, {}, success, complete)
}

/**
 * 删除组织信息
 * @param ids
 * @param success
 * @param complete
 */
function deleteOrganization(ids, success, complete) {
  postRequest(organizationApi.removeOrganization, {}, ids, success, complete)
}

/**
 *
 * @param ids
 * @param success
 * @param complete
 */
function deleteSingleOrganization(id, success, complete) {
  let ids = []
  ids.push(id)
  deleteOrganization(ids, success, complete)
}

export default {
  listOrganization,
  listAllOrganization,
  addOrganization,
  updateOrganization,
  getOrganizationById,
  deleteOrganization,
  deleteSingleOrganization
}
